//
//  StatusIndicator_Customer.swift
//  TestScroll
//
//  Created by kkkelicheng on 2021/12/7.
//

import Foundation
import UIKit

class StatusIndicator_Customer: UIView , StatusActionRequired {
    var statusAction: (() -> Void)?
    
    lazy var greenView: UIView = {
        let v = UIView.init(frame: .zero)
        v.backgroundColor = .green
        v.addGestureRecognizer(UITapGestureRecognizer.init(target: self, action: #selector(greenViewClick)))
        return v
    }()
    
    lazy var label: UILabel = {
        let l = UILabel.init(frame: .zero)
        l.text = "自定view"
        l.textColor = .lightGray
        return l
    }()
    
    init() {
        super.init(frame: .zero)
        backgroundColor = .white
        configSubviews()
    }
    
    @objc func greenViewClick(){
        statusAction?()
    }
    
    func configSubviews() {
        addSubview(greenView)
        greenView.translatesAutoresizingMaskIntoConstraints = false
        greenView.centerXAnchor.constraint(equalTo: self.centerXAnchor).isActive = true
        greenView.centerYAnchor.constraint(equalTo: self.centerYAnchor).isActive = true
        greenView.widthAnchor.constraint(equalToConstant: 100).isActive = true
        greenView.heightAnchor.constraint(equalToConstant: 100).isActive = true

        addSubview(label)
        label.translatesAutoresizingMaskIntoConstraints = false
        label.topAnchor.constraint(equalTo: greenView.bottomAnchor, constant: 20).isActive = true
        label.centerXAnchor.constraint(equalTo: self.centerXAnchor, constant: 0).isActive = true
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
